<template>
  <div class="Card">
    <div v-for="item in CardLists"
         :key="item.id">
      <h6 class="datetitle"
          v-if="item.isShow">{{item.comingTitle}}</h6>
      <van-card class="item">
        <template #thumb>
          <img :src="item.img | imgFilter"
               alt="无法显示图片"
               class="item_img">
        </template>
        <template #title>
          <div class="left">
            <div class="title">
              {{item.nm}}
            </div>
            <div class="detail">
              <div class="wish">
                <span class="wishes">{{item.wish}}</span>
                人想看
              </div>
              <div class="actors">
                主演:
                <span>{{item.star}}</span>
              </div>
              <div class="show-info">
                {{item.showInfo?item.showInfo: ''}}
                <span v-if="!item.showInfo">
                  {{item.rt +' 本'}}{{item.comingTitle|dataFmt}}{{'上映'}}
                </span>
              </div>
            </div>
          </div>
          <div class="right">
            <button :style="{'background-color':item.showst==4?'#0094ff':'#faaf00'}">{{item.showst|showstFilter}}</button>
          </div>
        </template>
      </van-card>
    </div>

  </div>
</template>
<script>
export default {
  props: {
    CardList: Array
  },
  data () {
    return {
      CardLists: []
    }
  },
  created () {
    // this.$nextTick(function () {
    //   this.addisShow()
    // })
  },
  filters: {
    showstFilter (val) {
      return val === 1 ? '想看' : val === 4 ? '预售' : '购物'
    },
    dataFmt (arg) {
      console.log(arg.split(' ')[1])
      return arg.split(' ')[1]
    }
  },
  watch: {
    CardList: function () {
      this.CardLists = this.CardList
      let date = ''
      this.CardLists.forEach((el, index) => {
        if (date !== el.comingTitle) {
          date = el.comingTitle
          el.isShow = true
        } else {
          el.isShow = false
        }
      })
    }
  },
  methods: {
  }
}
</script>
<style lang="scss" scoped>
.Card {
  .datetitle {
    background-color: #fff;
    padding: 0 15px;
    margin: 0;
  }
  .item {
    height: 114px;
    margin: 0;
    border-bottom: 1px solid #dddb8e;
    padding: 0 15px;
    .van-card__header {
      // overflow: hidden;
      .van-card__thumb {
        margin-top: 12px;
        width: 65px;
        margin-right: 10px;
        .item_img {
          width: 64px;
          height: 90px;
          border-radius: 0;
        }
      }
      .van-card__content {
        margin-top: 12px;
        > div {
          display: flex;
          align-items: center;
          justify-content: space-between;
          .left {
            color: #666;
            font-size: 13px;
            width: 240px;
            .title {
              color: #333;
              font-size: 17px;
              font-weight: bold;
            }
            .actors,
            .show-info {
              margin-top: 3px;
              white-space: nowrap;
              text-overflow: ellipsis;
              overflow: hidden;
              word-break: break-all;
              width: 100%;
            }
            .score .sc,
            .wish .wishes {
              color: #faaf00;
              font-size: 15px;
              font-weight: bold;
            }
          }
          .right {
            button {
              width: 47px;
              height: 27px;
              color: #fff;
              font-size: 12px;
              font-weight: bold;
              text-align: center;
              line-height: 27px;
              border-radius: 5px;
              background-color: #f03d37;
            }
          }
        }
      }
    }
  }
}
</style>
